﻿/**
* File: TpmapppermissionsController.cs
* Author: 汪杰
* Create Time:2021-11-18 9:04:53
* Email:15200358008@139.com
* 代码由TMCodeGenerator自动生成
**/
using JSLCloud.App.Mes.Service;
using JSLCloud.App.Models.Tpmapppermissions;
using JSLCloud.Models;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace JSLCloud.App.Mes.Controllers
{
    /// <summary>
    /// t_pm_app_permissions Controller
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class TpmapppermissionsController : ControllerBase
    {
        private readonly ITpmapppermissionsService _service;
        
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public TpmapppermissionsController(ITpmapppermissionsService service)
        {
            _service = service;
        }
        
        /// <summary>
        /// 获取t_pm_app_permissions数据表数据
        /// </summary>
        /// <param name="requestObject">返回响应结果</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResponseObject<List<TpmapppermissionsQueryModel>>> Get(string requestObject)
        {
            var request = JsonConvert.DeserializeObject<RequestGet>(requestObject);
            return await _service.GetAsync(request);
        }

        /// <summary>
        /// 根据角色查询
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("[action]")]
        public async Task<ResponseObject<TpmapppermissionsQueryModel>> GetByRoleId(int roleId)
        {
            return await _service.GetByRoleIdAsync(roleId);
        }

        /// <summary>
        /// 新增t_pm_app_permissions数据表数据，支持批量新增
        /// </summary>
        /// <param name="requestObject">返回响应结果</param>
        [HttpPost]
        [HttpOptions]
        public async Task<ResponseObject<bool>> Post(RequestPost<TpmapppermissionsAddModel> requestObject)
        {
            return await _service.PostAsync(requestObject);
        }
        
        /// <summary>
        /// 修改t_pm_app_permissions数据表数据，支持批量修改
        /// </summary>
        /// <param name="requestObject">返回响应结果</param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ResponseObject<bool>> Put(RequestPut<TpmapppermissionsEditModel> requestObject)
        {
            return await _service.PutAsync(requestObject);
        }
        
        /// <summary>
        /// 删除t_pm_app_permissions数据表数据
        /// </summary>
        /// <param name="requestObject">返回响应结果</param>
        [HttpDelete]
        public async Task<ResponseObject<bool>> Delete(RequestDelete<DeleteModel> requestObject)
        {
            return await _service.DeleteAsync(requestObject);
        }
    }
}
